'use strict';
module.exports = agent => {
  agent.logger.info('init websocket Server');
  agent.messenger.on('egg-ready', async () => {
    // console.log('license', await generateLicense());
    // worker_pid = agent.messenger.opids[0];
    // agent.messenger.sendTo(worker_pid, 'initServer');
    agent.logger.info('init success');
  });
  /**
   * 进程销毁或新增都会有此回调
   */
  agent.messenger.on('egg-pids', data => {
    const pids = data;
    // if (worker_pid && !pids.includes(worker_pid)) {
    //   worker_pid = agent.messenger.opids[0];
    //   agent.messenger.sendTo(worker_pid, 'initServer');
    //   agent.logger.info('websocket server restart');
    // }
  });
};
